Let's insert the value 101 into our current max-heap.
- Initial Heap:
[100, 19, 36, 17, 3, 25, 1]
- Step 1: Add to end
The new element is placed at the end of the array to maintain the complete tree property. - Step 2: Bubble Up
The new element is repeatedly compared with its parent and swapped upwards until the max-heap property is restored.
Array Representation